<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API测试</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        button {
            background: #4CAF50;
            color: white;
            border: none;
            padding: 10px 15px;
            margin: 10px 0;
            cursor: pointer;
            border-radius: 4px;
        }
        button:hover {
            background: #45a049;
        }
        .result {
            background: #f0f0f0;
            padding: 15px;
            border-radius: 4px;
            margin-top: 20px;
            white-space: pre-wrap;
            font-family: monospace;
            max-height: 400px;
            overflow-y: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>学生信息API测试</h1>
        <button onclick="testStudentList()">测试学生列表API</button>
        <div id="result" class="result">等待测试结果...</div>
    </div>

    <script>
        // 设置axios默认配置
        axios.defaults.baseURL = 'http://localhost:8080';
        axios.defaults.withCredentials = true;

        async function testStudentList() {
            const resultDiv = document.getElementById('result');
            resultDiv.textContent = '正在测试...';
            
            try {
                const response = await axios.get('/system/student/list');
                resultDiv.textContent = JSON.stringify(response.data, null, 2);
                console.log('API响应:', response.data);
            } catch (error) {
                if (error.response) {
                    resultDiv.textContent = `错误: ${error.message}\n状态码: ${error.response.status}\n响应数据: ${JSON.stringify(error.response.data, null, 2)}`;
                } else {
                    resultDiv.textContent = `错误: ${error.message}`;
                }
                console.error('API调用失败:', error);
            }
        }
    </script>
</body>
</html>